Allow domain config file to specify credit-scheduler parameters.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 23 Oct 2006 11:28:33 +0000 (12:28 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 23 Oct 2006 11:28:33 +0000 (12:28 +0100)
Signed-off-by: Masami Watanabe <masami.watanabe@jp.fujitsu.com>
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/create.py

index 0642b3a8cd2eebd3d40f64b4cee00f70f43b0d48..15a3934b1234811efcedb5afea7057e8cf623d67 100644 (file)
@@ -227,6 +227,9 @@ class XendDomain:
         try:
             dominfo = XendDomainInfo.create(config)
             self._add_domain(dominfo)
+            self.domain_sched_credit_set(dominfo.getDomid(),
+                                         dominfo.getWeight(),
+                                         dominfo.getCap())
             return dominfo
         finally:
             self.domains_lock.release()
index 748d7fe7f101c1aa93c526c1d19e4f4799fb1a49..a469b93a063c61e5440eefe1adc62b46c310d4c5 100644 (file)
@@ -131,7 +131,8 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [
     ('uuid',            str),
     ('vcpus',           int),
     ('vcpu_avail',      int),
-    ('cpu_weight',      float),
+    ('cpu_cap',         int),
+    ('cpu_weight',      int),
     ('memory',          int),
     ('shadow_memory',   int),
     ('maxmem',          int),
@@ -562,7 +563,8 @@ class XendDomainInfo:
             defaultInfo('features',     lambda: "")
             defaultInfo('cpu',          lambda: None)
             defaultInfo('cpus',         lambda: [])
-            defaultInfo('cpu_weight',   lambda: 1.0)
+            defaultInfo('cpu_cap',      lambda: 0)
+            defaultInfo('cpu_weight',   lambda: 256)
 
             # some domains don't have a config file (e.g. dom0 )
             # to set number of vcpus so we derive available cpus
@@ -826,6 +828,12 @@ class XendDomainInfo:
     def getResume(self):
         return "%s" % self.info['resume']
 
+    def getCap(self):
+        return self.info['cpu_cap']
+
+    def getWeight(self):
+        return self.info['cpu_weight']
+
     def endRestore(self):
         self.setResume(False)
 
index 48486d8bfc27c055996bea51c289d0a2a4fec1cb..fa1f23f771717c475e5e497c79e9bed860c405b0 100644 (file)
@@ -189,10 +189,14 @@ gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
           use="# of Virtual CPUS in domain.")
 
+gopts.var('cpu_cap', val='CAP',
+          fn=set_int, default=None,
+          use="""Set the maximum amount of cpu.
+          CAP is a percentage that fixes the maximum amount of cpu.""")
+
 gopts.var('cpu_weight', val='WEIGHT',
-          fn=set_float, default=None,
-          use="""Set the new domain's cpu weight.
-          WEIGHT is a float that controls the domain's share of the cpu.""")
+          fn=set_int, default=None,
+          use="""Set the cpu time ratio to be allocated to the domain.""")
 
 gopts.var('restart', val='onreboot|always|never',
           fn=set_value, default=None,
@@ -687,6 +691,8 @@ def make_config(vals):
         config.append(['cpu', vals.cpu])
     if vals.cpus is not None:
         config.append(['cpus', vals.cpus])
+    if vals.cpu_cap is not None:
+        config.append(['cpu_cap', vals.cpu_cap])
     if vals.cpu_weight is not None:
         config.append(['cpu_weight', vals.cpu_weight])
     if vals.blkif: